برنامه ی ساعت آنالوگ در پاسکال
program clock;
uses graph,crt,windos,dos;
var
gd,gm,
xcenter,ycenter,i,j,h,x,y,a,b,c,d,t,l,n,m,s,z,u,u1:integer;
r,x1 : array[1..10000] of integer;
p:real;
f: text;
h2, m2, s2, hund : Word;
ftime : longint;
dt : datetime;
function leadingzero(w : word) : string;
var
s2 : String;
begin
clrscr;
str(w:0,s2);
if length(s2) = 1 then
s2 := '0' + s2;
leadingzero := s2;
end;
begin
assign(f, 'test.txt');
getTime(h2,m2,s2,hund);
rewrite(f);
getFTime(f,ftime);
close(f);
n:=220;
s:=h2;
z:=m2;
u1:=12 - (z mod 12);
r[1]:=70;
r[2]:=10;
r[3]:=570;
r[4]:=470;
initgraph(gd,gm,'');
x1[1]:=84;
x1[2]:=24;
x1[3]:=1;
x1[4]:=1;
for l:=1 to 10 do
begin
setcolor(lightgreen);
rectangle(r[1],r[2],r[3],r[4]);
r[1]:=r[1]+1;
r[2]:=r[2]+1;
r[3]:=r[3]-1;
r[4]:=r[4]-1;
end;
repeat
settextstyle(defaultfont,horizdir,1);
setcolor(yellow);
outtextxy(313,30,'12');
outtextxy(530,236,'3');
outtextxy(317,447,'6');
outtextxy(105,236,'9');
outtextxy(420,55,'1');
outtextxy(495,130,'2');
outtextxy(495,345,'4');
outtextxy(420,420,'5');
outtextxy(208,418,'7');
outtextxy(135,343,'8');
outtextxy(135,130,'10');
outtextxy(208,55,'11');
p:=3.141592;
for d:=1 to 12 do
begin
setcolor(lightgreen);
j:=d*7;
x:=round(320)+round(190*cos(p*j/42));
y:=round(240)+round(190*sin(p*j/42));
circle(x,y,3);
end;
for t:=1 to 60 do
begin
j:=t*7;
x:=round(320)+round(190*cos(p*j/210));
y:=round(240)+round(190*sin(p*j/210));
putpixel(x,y,lightgreen);
end;
x1[1]:=x1[1]+x1[3];
x1[2]:=x1[2]+x1[4];
circle(x1[1],x1[2],4);
setcolor(black);
delay(4);
circle(x1[1],x1[2],4);
setcolor(lightred);
if x1[2] = 456 then
begin
x1[4]:=-1;
end;
if x1[1] = 556 then
x1[3]:=-1;
if x1[2] = 24 then
begin
x1[4]:=0+1;
end;
if x1[1] = 84 then
x1[3]:=0+1;
{--------------------------------------------------------------------------}
setcolor(lightblue);
i:=i+1;
a:=a+1;
j:=i*7;
x:=round(320)+round(180*cos(p*j/210-p/2));
y:=round(240)+round(180*sin(p*j/210-p/2));
line(x,y,320,240);
setcolor(black);
delay(2); { 455 } { 214 }
line(x,y,320,240);
setcolor(lightblue);
j:=b*7;
x:=round(320)+round(140*cos(p*j/210-p/2+(z / 5)*30*p/180));
y:=round(240)+round(140*sin(p*j/210-p/2+(z / 5)*30*p/180));
setcolor(yellow);
line(x,y,320,240);
if a = 60 then
begin
setcolor(black);
line(x,y,320,240);
b:=b+1;
a:=0;
m:=m+1;
end;
j:=c*7;
x:=round(320)+round(100*cos(p*j/210-p/2+(s*30+((z div 12)*6))*p/180));
y:=round(240)+round(100*sin(p*j/210-p/2+(s*30+((z div 12)*6))*p/180));
setcolor(lightred);
line(x,y,320,240);
if m = u1 then
begin
setcolor(black);
line(x,y,320,240);
c:=c+1;
m:=0;
u1:=12;
end;
setcolor(lightgreen);
circle(320,240,4);
until keypressed;
readln;
closegraph;
end
uses graph,crt,windos,dos;
var
gd,gm,
xcenter,ycenter,i,j,h,x,y,a,b,c,d,t,l,n,m,s,z,u,u1:integer;
r,x1 : array[1..10000] of integer;
p:real;
f: text;
h2, m2, s2, hund : Word;
ftime : longint;
dt : datetime;
function leadingzero(w : word) : string;
var
s2 : String;
begin
clrscr;
str(w:0,s2);
if length(s2) = 1 then
s2 := '0' + s2;
leadingzero := s2;
end;
begin
assign(f, 'test.txt');
getTime(h2,m2,s2,hund);
rewrite(f);
getFTime(f,ftime);
close(f);
n:=220;
s:=h2;
z:=m2;
u1:=12 - (z mod 12);
r[1]:=70;
r[2]:=10;
r[3]:=570;
r[4]:=470;
initgraph(gd,gm,'');
x1[1]:=84;
x1[2]:=24;
x1[3]:=1;
x1[4]:=1;
for l:=1 to 10 do
begin
setcolor(lightgreen);
rectangle(r[1],r[2],r[3],r[4]);
r[1]:=r[1]+1;
r[2]:=r[2]+1;
r[3]:=r[3]-1;
r[4]:=r[4]-1;
end;
repeat
settextstyle(defaultfont,horizdir,1);
setcolor(yellow);
outtextxy(313,30,'12');
outtextxy(530,236,'3');
outtextxy(317,447,'6');
outtextxy(105,236,'9');
outtextxy(420,55,'1');
outtextxy(495,130,'2');
outtextxy(495,345,'4');
outtextxy(420,420,'5');
outtextxy(208,418,'7');
outtextxy(135,343,'8');
outtextxy(135,130,'10');
outtextxy(208,55,'11');
p:=3.141592;
for d:=1 to 12 do
begin
setcolor(lightgreen);
j:=d*7;
x:=round(320)+round(190*cos(p*j/42));
y:=round(240)+round(190*sin(p*j/42));
circle(x,y,3);
end;
for t:=1 to 60 do
begin
j:=t*7;
x:=round(320)+round(190*cos(p*j/210));
y:=round(240)+round(190*sin(p*j/210));
putpixel(x,y,lightgreen);
end;
x1[1]:=x1[1]+x1[3];
x1[2]:=x1[2]+x1[4];
circle(x1[1],x1[2],4);
setcolor(black);
delay(4);
circle(x1[1],x1[2],4);
setcolor(lightred);
if x1[2] = 456 then
begin
x1[4]:=-1;
end;
if x1[1] = 556 then
x1[3]:=-1;
if x1[2] = 24 then
begin
x1[4]:=0+1;
end;
if x1[1] = 84 then
x1[3]:=0+1;
{--------------------------------------------------------------------------}
setcolor(lightblue);
i:=i+1;
a:=a+1;
j:=i*7;
x:=round(320)+round(180*cos(p*j/210-p/2));
y:=round(240)+round(180*sin(p*j/210-p/2));
line(x,y,320,240);
setcolor(black);
delay(2); { 455 } { 214 }
line(x,y,320,240);
setcolor(lightblue);
j:=b*7;
x:=round(320)+round(140*cos(p*j/210-p/2+(z / 5)*30*p/180));
y:=round(240)+round(140*sin(p*j/210-p/2+(z / 5)*30*p/180));
setcolor(yellow);
line(x,y,320,240);
if a = 60 then
begin
setcolor(black);
line(x,y,320,240);
b:=b+1;
a:=0;
m:=m+1;
end;
j:=c*7;
x:=round(320)+round(100*cos(p*j/210-p/2+(s*30+((z div 12)*6))*p/180));
y:=round(240)+round(100*sin(p*j/210-p/2+(s*30+((z div 12)*6))*p/180));
setcolor(lightred);
line(x,y,320,240);
if m = u1 then
begin
setcolor(black);
line(x,y,320,240);
c:=c+1;
m:=0;
u1:=12;
end;
setcolor(lightgreen);
circle(320,240,4);
until keypressed;
readln;
closegraph;
end
نظرات شما عزیزان: